package cn.edu.zxj.ojspring.model;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description：
 *
 * @author: zxj
 * @date: 2024-02-21
 * @time: 17:09:50
 */
@Data
public class Result {
    // 业务处理逻辑代码, 200 表示成功, -1 表示出现错误
    private Integer code;
    // 错误信息
    private String errMessage;
    // 返回的数据
    private Object data;


    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(200);
        result.setErrMessage("");
        result.setData(data);
        return result;
    }


    public static Result fail(Object data,String errMessage) {
        Result result = new Result();
        result.setCode(-1);
        result.setErrMessage(errMessage);
        result.setData(data);
        return result;
    }

    public static Result fail(String errMessage) {
        Result result = new Result();
        result.setCode(-1);
        result.setErrMessage(errMessage);
        return result;
    }
}
